 var id=0;
 
 function getPicUrl(id){
	 var pic=document.getElementById(id);
	 if(pic==null)
		return getPicUrl(0);
	 return pic.href;
 }	
 
 function show(e){
	 	 
	 document.getElementById("preview").style.display="inline";
	 id=parseInt(e.id);
	 document.getElementById("preview").innerHTML=""+
	 "<div style=\"position:absolute;top:0;left:0;width:100%;height:100%;z-index:0;\" onclick=\"hide()\"></div>"+
	 "<div  style=\"position:absolute;top:30px;left:30%;width:40%;z-index:5;\" >"+
		"<img id=\"picprevM1\" style=\"width:0;display:none\" src=\""+getPicUrl(id-1)+"\"/> "+
		"<img id=\"picprevP1\" style=\"width:0;display:none\" src=\""+getPicUrl(id+1)+"\"/> "+
		"<div style=\"position:absolute;top:0px;left:0px;height:100%;width:10%;\" onclick=\"prev()\">&lt- </div>"+
		"<a id=\"linkId\" href =\""+getPicUrl(id)+"\" target=\"_blank\" ><img id=\"picprev\"  style=\"width:100%;\" src=\""+getPicUrl(id)+"\"/> </a>"+	
	   "<div style=\"position:absolute;top:0px;right:0px;height:100%;width:10%; \" onclick=\"next()\"> -&gt</div>"+
	 "</div>";
	 document.getElementById("preview").style.zIndex=2;
	 
	 return false;
 }	 	
 function hide(){
	 document.getElementById("preview").style.zIndex=0;
	 document.getElementById("preview").style.display="none";
	 
 }	 
 function next(){
	 id=parseInt(id)+1;
	 
	 if(document.getElementById(id)==null) // element nicht mehr vorhanden
		id--;
	 document.getElementById("picprev").src=getPicUrl(id);
	 document.getElementById("linkId").href=getPicUrl(id);
	 
	 document.getElementById("picprevM1").src=getPicUrl(id-1);
	 document.getElementById("picprevP1").src=getPicUrl(id+1);
	 	  
 }	 
  function prev(){
	 id=parseInt(id)-1;
	 
	 if(document.getElementById(id)==null) // element nicht mehr vorhanden
		id++;
	 document.getElementById("picprev").src=getPicUrl(id);
	  document.getElementById("linkId").href=getPicUrl(id);
	 document.getElementById("picprevM1").src=getPicUrl(id-1);
	 document.getElementById("picprevP1").src=getPicUrl(id+1);
	 	  
 }	
